<style lang="scss" rel="stylesheet/scss">
    .j-header {
        height:45px;
        line-height: 45px;
        display: flex;
        text-align: center;
        background: #4DCC01;
        color: #fff;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 99;
        .left ,.right-setting {
            flex:0 0 80px;
        }
        .center-txt {
            flex:1;
            
        }
    }
</style>
<template>
    <div class="j-header">
        <div class="iconfont icon-fanhui font-big-small left" @click="toback">返回</div>
        <div class="center-txt font-big">{{title}}</div>
        <div class="right-setting font-big-small" v-if="!hasjubao" @click="toindex">首页</div>
        <div class="right-setting font-big-small" v-else @click="jubao">举报</div>
        <van-popup v-model="jbao.popShow" position="bottom">
            <van-picker show-toolbar :columns="jbao.popList" @cancel="onCanceljubao" @confirm="selectjubao" />
        </van-popup>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                jbao: {
                    popShow: false,
                    popList: ['虚假信息', '垃圾广告', '侵权抄袭', '涉黄涉毒', '政治敏感', '其他']
                },
            }
        },
        props: {
            title:{
                type:String,
                default:'详情页'
            },
            hasjubao: {
                default:false,
                type: Boolean
            },
            id: {
                type:[Number, String]
            }
        },
        created () {

        },
        methods: {
            toback() {
                if (window.history.length <= 1) {
                    this.toindex()
                }else {
                    this.$router.go(-1)
                }
            },
            toindex() {
                window.location.href = xmconfig.Index_url
            },
            jubao() {
                this.jbao.popShow = true
            },
            selectjubao(value, index) {
                let infoobj = JSON.parse(sessionStorage.getItem('infoObj'))
                xmview.getKey('detail-comment-report', infoobj.unionid).then(key => {
                    let params = {
                        comment_id: this.id,
                        content: value
                    }
                    this.$post(`${xmconfig.API_YI}/v1/detail-comment-report?unionid=${infoobj.unionid}&key=${key}`,params).then(res => {
                        if(res.code === 200) {
                            this.jbao.popShow = false
                            xmview.showToast(res.msg)
                        }
                    })
                })
            },
            onCanceljubao() {
                this.jbao.popShow = false
            },
        }
    }
</script>

